<template>
  <div class="share">
    <div v-for="(item, index) in list" :key="index" class="content">
      <div class="item">
        <span class="item-label">镜像名称</span>
        <el-popover placement="bottom" width="200" trigger="hover" :content="item.imageName">
          <el-link slot="reference" type="primary" class="item-value" @click="goUrl(item.imageUrl)">
            {{ item.imageName ? item.imageName : '-' }}
          </el-link>
        </el-popover>
      </div>
      <div class="item">
        <span class="item-label">适用操作系统</span>
        <span class="item-value">{{ item.ops ? item.ops : '-' }}</span>
      </div>
      <div class="item">
        <span class="item-label">附件信息</span>
        <span class="item-value">
          <el-link type="primary" @click="goUrl(item.attachmentUrl)">{{ item.attachmentName ? item.attachmentName : '-' }}</el-link>
        </span>
      </div>
      <div class="item">
        <span class="item-label">镜像说明</span>
        <span class="item-value">{{ item.remark ? item.remark : '-' }}</span>
      </div>
    </div>
  </div>
</template>

<script>
import { fetchImageShare } from '@/api/images'
export default {
  name: 'Share',
  data() {
    return {
      image: {},
      list: [],
    }
  },
  mounted() {
    this.image = this.$route.query;
    this.getShare(this.image.type, this.image.id)
  },
  methods: {
    goUrl(url) {
      window.open(url);
    },
    getShare(type, shareId) {
      fetchImageShare({ type, shareId }).then(res => {
        console.log(res);
        this.list = res.data;
      }).catch(err => {
        console.log(err)
      })
    }
  }
}
</script>

<style scoped>
.share {
  padding-top: 30px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.content {
  width: 500px;
  padding: 0 20px;
  margin-bottom:20px ;
  border-bottom: 1px solid #ccc;
  color: #606266;
}
.title {
  font-size: 16px;
  font-weight: 700;
}
.item {
  margin: 5px 0;
  padding: 0 10px;
  display: flex;
  justify-content: space-between;
  line-height: 30px;
}
.item-label {
  display: block;
  width: 160px;
  color: #909399;
}
.item-value {
  display: block;
  width: 200px;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
</style>
